<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="/js/html5.js"></script>
<script type="text/javascript" src="/js/respond.min.js"></script>
<script type="text/javascript" src="/js/PIE_IE678.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="/css/H-ui.css"/>
<link type="text/css" rel="stylesheet" href="/css/H-ui.admin.css"/>
<link type="text/css" rel="stylesheet" href="/font/font-awesome.min.css"/>
<!--[if IE 7]>
<link href="/font/font-awesome-ie7.min.css" rel="stylesheet" type="text/css" />
<![endif]-->
<title>分类管理</title>
</head>
<body>
<nav class="Hui-breadcrumb"><i class="icon-home"></i> 首页 <span class="c-gray en">&gt;</span> 资讯管理 <span class="c-gray en">&gt;</span> 分类管理 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="icon-refresh"></i></a></nav>
<div class="pd-20 text-c">
  <form class="Huiform">
    <input type="hidden" id="hid_ccid" value="">
    <input class="input-text" style="width:250px" type="text" value="" placeholder="输入分类" id="article-class-val"><button type="button" class="btn btn-success" id="" name="" onClick="articleTypeAdd();"><i class="icon-plus"></i> 添加</button>
  </form>
  <div class="article-class-list cl mt-20">
    <table class="table table-border table-bordered table-hover table-bg">
      <thead>
        <tr class="text-c">
          <th width="25"><input type="checkbox" name="" value=""></th>
          <th width="80">ID</th>
          <th>分类名称</th>
          <th width="70">操作</th>
        </tr>
      </thead>
      <tbody id="articleType">
        <tr class="text-c">
          <td><input type="checkbox" name="" value=""></td>
          <td>1</td>
          <td>1</td>
          <td class="text-l">一级分类</td>
          <td class="f-14"><a title="编辑" href="javascript:;" onClick="article_class_edit('1','620','160','分类编辑','article-class-edit.html')" style="text-decoration:none"><i class="icon-edit"></i></a> <a title="删除" href="javascript:;" onClick="article_class_del(this,'1')" class="ml-5" style="text-decoration:none"><i class="icon-trash"></i></a></td>
        </tr>
        <tr class="text-c">
          <td><input type="checkbox" name="" value=""></td>
          <td>2</td>
          <td>2</td>
          <td class="text-l">&nbsp;&nbsp;├&nbsp;二级分类</td>
          <td class="f-14"><a title="编辑" href="javascript:;" onClick="article_class_edit('2','620','160','分类编辑','article-class-edit.html')" style="text-decoration:none"><i class="icon-edit"></i></a> <a title="删除" href="javascript:;" onClick="article_class_del(this,'2')" class="ml-5" style="text-decoration:none"><i class="icon-trash"></i></a></td>
        </tr>
        <tr class="text-c">
          <td><input type="checkbox" name="" value=""></td>
          <td>3</td>
          <td>3</td>
          <td class="text-l">&nbsp;&nbsp;├&nbsp;二级分类</td>
          <td class="f-14"><a title="编辑" href="javascript:;" onClick="article_class_edit('3','620','160','分类编辑','article-class-edit.html')" style="text-decoration:none"><i class="icon-edit"></i></a> <a title="删除" href="javascript:;" onClick="article_class_del(this,'3')" class="ml-5" style="text-decoration:none"><i class="icon-trash"></i></a></td>
        </tr>
      </tbody>
    </table>
  </div>
</div>
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/Validform_v5.3.2_min.js"></script>
<script type="text/javascript" src="/layer/layer.min.js"></script>
<script type="text/javascript" src="/js/H-ui.js"></script>
<script type="text/javascript" src="/js/H-ui.admin.js"></script>

</body>
</html>
<script>
  $(function () {
      findArticleType();
  })
  function findArticleType() {
      $.ajax({
        url : "/articleType",
        type : "get",
        dataType:"json",
        success : function (data) {
          console.log(data)
          apendArticleType(data.data);
        }
      })

  }

  function apendArticleType(articleType) {
      var html = '';
    for (var i = 0; i < articleType.length; i++) {
      html += '<tr class="text-c">'
      html += '<td><input type="checkbox" name="" value=""></td>'
      html += '<td>'+articleType[i].id+'</td>'
      html += '<td class="text-l">'+articleType[i].title+'</td>'
      html += '<td class="f-14"><a title="编辑" href="javascript:;" onClick="article_class_edit(\'620\',\'160\',\'分类编辑\',\'/toArticleTypeUpdate/' + articleType[i].id + '\')" style="text-decoration:none"><i class="icon-edit"></i></a> <a title="删除" href="javascript:;" onClick="article_class_del(this,'+articleType[i].id+')" class="ml-5" style="text-decoration:none"><i class="icon-trash"></i></a></td>'
      html += '</tr>'
    }

    $("#articleType").html(html);
  }

  function articleTypeAdd() {
      var title = $("#article-class-val").val();
      if (title == null || title == '') {
        alert("请输入分类")
      } else {
        $.ajax({
          url : "/articleType",
          type : "post",
          dataType : "json",
          data : {"title":title},
          success : function (data) {
              if (data.code == 200) {
                alert("添加成功");
                window.location.reload();
              } else {
                alert("添加失败")
              }
          }
        })
      }
  }
</script>
<!--代码整理：js代码 www.jsdaima.com-->